<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no">
		<title>51微贷</title>
		<link rel="stylesheet" type="text/css" href="../css/reset.css">
		<link rel="stylesheet" type="text/css" href="../css/common.css">
		<link rel="stylesheet" type="text/css" href="../css/icomoon/style.css">
		<link rel="stylesheet" type="text/css" href="../css/listloading.base.css">
		<link rel="stylesheet" type="text/css" href="../css/listloading.min.css">
		<script type="text/javascript" src="../js/rem.js"></script>
		<script type="text/javascript" src="../js/zepto.min.js"></script>
		<script type="text/javascript" src="../js/require.js"></script>
		<script type="text/javascript" src="../js/listloading.iconfont.js"></script>
	</head>
	<style>
		#wrapper{ position: absolute; width: 100%; bottom: 0; top: 1.5rem; }
	</style>
	<body onload="loaded()">
		<div id="content">
			<h3 class="header f-pr">
				<span>提现记录</span> 
				<i class="icon-angle-left f-pa"></i>
			</h3>
			<div class="m-fundsflowdetail" style="overflow: hidden;">				
				<div class="detail">
					<div id="withdrawal"></div>
				</div>
				<div id="wrapper">
					<div id="scroller">
						<div class="nodata nodata-1 hide">
							<p class="img"><img src="../images/nodata-1.png"></p>
							<p class="text">暂无数据</p>
						</div>
					</div>
				</div>
			</div>
		</div>

		<script type="text/javascript" src="../js/mui.min.js"></script>
		<script type="text/javascript" src="../js/common.js"></script>
		<script type="text/javascript" src="../js/iscroll.js"></script>
		<script type="text/javascript" src="../js/scroller.js"></script>

		<script type="text/javascript">
			require.config({
				paths: {
					'iscroll': '../js/iscroll.min',
					'listloading': '../js/listloading.min',
					'encryption': '../js/md5.min'
				}
			});

			mui.plusReady(function(){
				require(['iscroll', 'listloading','encryption'], function(){
					var md5 = require('encryption');
					var Listloading = require('listloading');
					var page_index = 1, page_size = 8, page_count = 10;

					$('.m-fundsflowdetail, .listloadingClass').height($(window).height() - 20);

					var withdrawal = function(cb, flag, page_index, page_size){
						if(flag){
							return cb(flag);
						}else{
							mui.ajax(base + 'account/withdrawallist', {
								type: 'get',
								data: {
									'id': parseInt(plus.storage.getItem('user_id')),
									'page_index': page_index,
									'page_size': page_size
								},
								dataType: 'json',
								headers: sign(md5),
								success: function(response){
									if(response.page_index == 1){
										$('#withdrawal').empty();
									}
									var data = response.data;
									page_index = response.page_index;
									page_count = response.page_count;
									
									if(data.length > 0){
										for(var i = 0, len = data.length; i < len; i++){
											var list = data[i].list, result = '';
											result += '<h3>' + data[i].month + '</h3>';
											result += '<ul class="child-list">';
											for(var j = 0, len_1 = list.length; j < len_1; j++){
												var item = list[j];
												result += '<li>';
												result += '<p class="date f-fl"><span class="day">' + item.date_month + '.' + item.date_day + '</span><span class="year">' + item.date_year + '年</span></p>';
												result += '<div class="info">';
												result += '<p><span>提现</span><span class="f-fr">' + item.amount + '</span></p>';
												result += '<p><span class="fee">' + item.name + '</span><span class="f-fr">' + item.status + '</span></p>';
												result += '</div>';
												result += '</li>';
											}
											result += '</ul>';
											$('#withdrawal').append(result);
										}
										cb(flag);
									}else if(data.length == 0 && (response.page_index == 1 || response.page_index == undefined)){
										$('.nodata').removeClass('hide');
										$('body').addClass('bg');
									}
								},
								error: function(data){
									console.error(data.message);
								}
							});
						}
					};

					var listloading = new Listloading('.m-fundsflowdetail', {
						disableTime: true,
						pullUpAction: function(cb){
							var flg = false;
							if(page_index + 1 > page_count){
								flg = true;
							}else{
								page_index++;
							}
							return withdrawal(cb, flg, page_index, page_size);
						},
						pullDownAction: function(cb, flg){
							page_index = 1;
							return withdrawal(cb, false, page_index, page_size);
						},
						Realtimetxt: '官人不要，请放开我！',
        				loaderendtxt: '我是有底线的',
        				iscrollOptions: {
		                    scrollbars: false   
		                }
					});
				});

				$('.icon-angle-left').on('tap', function(){
					mui.back();
				});
			});
		</script>
	</body>
</html>